﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.ComponentModel;
using System.Web.UI.WebControls;
using System.Xml;

namespace NuGet.Enterprise.Server.Configuration
{
    public abstract class BuildStoreConnectionSettings
        : ConfigurationElement
    {
        #region Properties
        
        [ConfigurationProperty("name", IsRequired = true, IsKey = true)]
        public string Name
        {
            get { return (string)this["name"]; }
            set { this["name"] = value; }
        }

        [ConfigurationProperty("type", IsRequired = true, IsKey = false)]
        public BuildStoreConnectionType Type
        {
            get { return (BuildStoreConnectionType)this["type"]; }
            set { this["type"] = value; }
        }

        [ConfigurationProperty("url", IsRequired = true, IsKey = false)]
        [TypeConverter(typeof(UriTypeConverter))]
        public Uri Url
        {
            get { return (Uri)this["url"]; }
            set { this["url"] = value; }
        }

        [ConfigurationProperty("quality", IsRequired = false, IsKey = false)]
        [TypeConverter(typeof(StringArrayConverter))]
        public string[] Quality
        {
            get { return (string[])this["quality"]; }
            set { this["quality"] = value; }
        }

        [ConfigurationProperty("credentials", IsRequired = false, IsKey = false)]
        public BuildStoreCredentials Credentials
        {
            get { return (BuildStoreCredentials)this["credentials"]; }
            set { this["credentials"] = value; }
        }

        [ConfigurationProperty("displayName", IsRequired = false, IsKey = false)]
        public string DisplayName
        {
            get { return (string)this["displayName"]; }
            set { this["displayName"] = value; }
        }

        #endregion

        #region Methods
        
        internal void DeserializeElementInternal(XmlReader reader, bool serializeCollectionKey)
        {
            base.DeserializeElement(reader, serializeCollectionKey);
        }

        #endregion
    }
}
